package com.sxt.convert;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

import com.sxt.entity.RGB;

public class Convert extends StrutsTypeConverter {

	@SuppressWarnings("rawtypes")
	@Override
	public Object convertFromString(Map context, String[] values, Class toClass) {
		String[] rgbs = values[0].split(",");
		return new RGB(Integer.parseInt(rgbs[0]), Integer.parseInt(rgbs[1]),
				Integer.parseInt(rgbs[2]));
	}

	@Override
	public String convertToString(@SuppressWarnings("rawtypes") Map context, Object o) {
		return ((RGB) o).toString();
	}

}
